#include<stdio.h>
#include<stdlib.h>

int g_val_1;
int g_val_2=100;

int main(int argc,int* argv[],char* env[]){
  //打印各区域地址分布
  //printf("code addr (main):%p\n",main);
  const char* str="hello bit";
  //printf("read only string addr:%p\n",str);
  //printf("init global value addr (g_val_2):%p\n",&g_val_2);
  //printf("init global value addr (g_val_1):%p\n",&g_val_1);
  char* mem=(char*)malloc(100);
  printf("heap addr:%p\n",mem);
  printf("stack addr (str):%p\n",&str);

//  //验证栈区与堆区的增长方向 
//  char* mem=(char*)malloc(100); 
//  char* mem1=(char*)malloc(100);
//  char* mem2=(char*)malloc(100);
//  printf("heap addr:%p\n",mem);
//  printf("heap addr:%p\n",mem1);
//  printf("heap addr:%p\n",mem2);
//
//  int a,b,c;
//  printf("stack addr (a):%p\n",&a);
//  printf("stack addr (b):%p\n",&b);
//  printf("stack addr (c):%p\n",&c);
//
  //静态变量地址与全局变量对比
  //static int a=0;
  //int b,c;

  //printf("global ini addr(g_val_2):%p\n",&g_val_2);
  //printf("static var addr(a):%p\n",&a);
  //printf("stack var addr(b):%p\n",&b);
  //printf("stack var addr(c):%p\n",&c);

  //环境变量的存储位置
  for(int i=0;env[i];++i){
    printf("env[%d] address:%p\n",i,env[i]);
  }
  return 0;
}
